//
//  HMSubscribeTitleView.m
//  subscribe
//
//  Created by 宋轩 on 17/1/3.
//  Copyright © 2017年 song. All rights reserved.
//

#import "HMSubscribeTitleView.h"
#import "UIColor+Addition.h"

//窗口宽高
#define SCREENWIDTH self.bounds.size.width
#define SCREENHEIGHT self.bounds.size.height

//导航滚动条高
#define HEIGHT 3

@implementation HMSubscribeTitleView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self createTitleView];
    }
    
    return self;
}

//titleView
- (void)createTitleView
{

    //已订
    UIButton *finishBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH * 0.5,SCREENHEIGHT)];
    [finishBtn setTitle:@"已订" forState:UIControlStateNormal];
    [finishBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self addSubview:finishBtn];
    
    //点击已订
    [finishBtn addTarget:self action:@selector(finishBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //推荐
    UIButton *recommendBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREENWIDTH * 0.5, 0, SCREENWIDTH * 0.5,SCREENHEIGHT)];
    [recommendBtn setTitle:@"推荐" forState:UIControlStateNormal];
    [recommendBtn setTitleColor:[UIColor colorWithHex:0x6e6960] forState:UIControlStateNormal];
    
    [self addSubview:recommendBtn];
    
    [recommendBtn addTarget:self action:@selector(recommendBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //滚动条
    UIView *pageIndexView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREENHEIGHT - HEIGHT, SCREENWIDTH * 0.5, HEIGHT)];
    pageIndexView.backgroundColor = [UIColor colorWithHex:0xfb831b];
    
    self.pageIndexView = pageIndexView;
    
    [self addSubview:pageIndexView];
    
    self.userInteractionEnabled = YES;
    
}

- (void)finishBtnClick:(UIButton *)btn
{
    self.btnBlock(@"已订");
}

- (void)recommendBtnClick:(UIButton *)btn
{
    self.btnBlock(@"推荐");
}


@end
